<template>
	<view>
		<view class="p-20">
			<view class="pt-20 pb-20 pl-40 pr-40 border-radius bg-white flex font-bold">
				<view v-if="type === 0">零活招聘: </view>
				<view v-if="type === 1">零工求职: </view>
				<view>{{info.title}}</view>
			</view>
			<view class="pt-20 pb-20 pl-40 pr-40 border-radius bg-white mt-20">
				<view>内容: </view>
				<view class="mt-20">
					{{info.info}}
				</view>
			</view>
		</view>
		<view class="pl-40 mt-20">其他推荐</view>
		<view class="pl-30 pr-30 pt-30" v-for="(item, index) in obbLists" :key="index"
			@click="$goRoute.goUrl('/pages/job_work/details?id='+item.id)">
			<view class="bg-white pl-30 pr-30 pt-20 pb-20 border-radius">
				<view>{{item.title}}</view>
				<view class="font-no-wrap2 mt-20 font-24 font-grey">{{item.info}}</view>
			</view>
		</view>
		
		<view class="bottom-view">
			<view class="bottom-btn font-white bg-g" @click="telphone()">立即联系</view>
		</view>
	</view>
</template>

<script>
	import {
		list as obbList,
		queryById
	} from '../../api/obb.js'
	export default {
		data() {
			return {
				id: 0,
				type: 0,
				pageNo: 1,
				pageSize: 10,
				obbLists: [],
				info: {}
			};
		},
		onLoad(options) {
			this.id = options.id
			this.getDetail()
			this.getObbList()
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: '河口人才招聘小程序',
				path: '/pages/job_work/details?id='+this.id
			}
		},
		onReachBottom() {
			this.getObbList()
		},
		methods: {
			telphone() {
				uni.makePhoneCall({
					phoneNumber: this.info.mobile
				});
			},
			getDetail() {
				queryById({
					id: this.id
				}).then(res => {
					this.info = res.result
				})
			},
			getObbList() {
				uni.showLoading({
					title: '加载中'
				})
				obbList({
					pageNo: this.pageNo,
					pageSize: 10,
					type: this.type
				}).then(res => {
					if (this.pageNo === 1) {
						this.obbLists = res.result.records
					} else {
						this.obbLists.push(...res.result.records)
					}
					this.pageNo += 1
					uni.hideLoading()
				})
			},
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f6f6f6;
		padding-bottom: 200rpx;
	}

	.bottom-view {
		width: 100vw;
		padding: 40rpx 0;
		background-color: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 99999;
		border-top: 1px solid #efefef;

		.bottom-btn {
			width: 80vw;
			margin: auto;
			text-align: center;
			border-radius: 50rpx;
			padding: 20rpx 0;
		}
	}
</style>